<template lang="pug">
  .aerial-introduction(@click="showIntroduction()" v-if="isDecExist")
    img(src="static/images/i.png")
</template>

<script>
import { mapGetters } from 'vuex'
export default {
  computed: {
    ...mapGetters(['panoInfo', 'sceneList']),
    // 没有简介不显示图标
    isDecExist() {
      if (this.panoInfo && this.sceneList) {
        // console.log('introduction-------------3')
        // console.log(this.panoInfo)
        // console.log(this.sceneList)
        let dec = this.getDec()
        if (dec) {
          return true
        } else {
          return false
        }
      }
    },
  },
  methods: {
    showIntroduction() {
      console.log('showIntroduction--------------')
      let title = this.getTitle()
      let text = this.getDec()
      this.$vgo.emit('model:intro', {
        title,
        text
      })
    },
    // 获取标题
    getTitle() {
      let title = ''
      if (location.href.indexOf('scene_id') === -1) {
        if (this.panoInfo) {
          title = this.panoInfo.pano_name
        }
      } else {
        let sceneId = this.$route.query.scene_id
        if (this.sceneList && this.sceneList.length > 0 && sceneId) {
          this.sceneList.map(item => {
            if (sceneId == item.scene_id) {
              title = item.title
            }
          })
        } else if (this.sceneList && this.sceneList.length > 0) {
          title = this.sceneList[0].title
        }
      }
      return title
    },
    // 获取描述
    getDec() {
      let dec = ''
      if (location.href.indexOf('scene_id') === -1) {
        if (this.panoInfo) {
          dec = this.panoInfo.pano_dec
        }
      } else {
        let sceneId = this.$route.query.scene_id
        if (this.sceneList && this.sceneList.length > 0 && sceneId) {
          this.sceneList.map(item => {
            if (sceneId == item.scene_id) {
              dec = item.dec
            }
          })
        } else if (this.sceneList && this.sceneList.length > 0) {
          dec = this.sceneList[0].dec
        }
      }
      return dec
    },
  }
}
</script>

<style lang="stylus" scoped>
.aerial-introduction
  position absolute
  z-index 4
  left 30px
  top 40px
  width 38px
  height 33px
  border-radius 50%
  cursor pointer
</style>
